
from fastapi import FastAPI
from starlette.staticfiles import StaticFiles

import models
from db import engine
from official import official_router
from product import product_put, product_delete, product_post, product_get
from root import root_post, root_delete, root_put, root_get, wxlogin
from user import user_get, user_post, user_delete, user_put
from fastapi.middleware.cors import CORSMiddleware




app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
    allow_origins=["127.0.0.1:8000/*","*"]

)

app.mount(path="/storage", app=StaticFiles(directory="./storage"), name="storage")




models.Base.metadata.create_all(bind=engine)


# user
app.include_router(user_get.router)
app.include_router(user_post.router)
app.include_router(user_delete.router)
app.include_router(user_put.router)

# root

app.include_router(root_get.router)
app.include_router(root_post.router)
app.include_router(root_delete.router)
app.include_router(root_put.router)

# product
app.include_router(product_get.router)
app.include_router(product_post.router)
app.include_router(product_delete.router)
app.include_router(product_put.router)


app.include_router(official_router.router)
app.include_router(wxlogin.router)

